# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=ruby-net-smtp
_gemname=net-smtp
# Keep version in sync with "Bundled gems" (https://stdgems.org) for the
# packaged Ruby version.
pkgver=0.4.0.1
pkgrel=0
pkgdesc="Simple Mail Transfer Protocol client library for Ruby"
url="https://github.com/ruby/net-smtp"
arch="noarch"
license="BSD-2-Clause AND Ruby"
depends="ruby"
checkdepends="ruby-rake ruby-test-unit"
makedepends="ruby-rdoc"
subpackages="$pkgname-doc"
source="https://github.com/ruby/net-smtp/archive/v$pkgver/$_gemname-$pkgver.tar.gz
	gemspec.patch
	"
builddir="$srcdir/$_gemname-$pkgver"

prepare() {
	default_prepare
	sed -i '/require .bundler/d' Rakefile
}

build() {
	gem build $_gemname.gemspec
}

check() {
	rake test
}

package() {
	local gemdir="$pkgdir/$(ruby -e 'puts Gem.default_dir')"

	gem install \
		--local \
		--install-dir "$gemdir" \
		--ignore-dependencies \
		--document ri \
		--verbose \
		$_gemname

	# Remove unnessecary files
	cd "$gemdir"
	rm -rf build_info cache extensions plugins
}

doc() {
	pkgdesc="$pkgdesc (ri docs)"

	amove "$(ruby -e 'puts Gem.default_dir')"/doc
}

sha512sums="
9fdacd9f7ec40bdec7467789574d3fff774583d983c9509a6335daeb8e811be531a43bf6ad3d7f2ebb1cc3bb8d0f1baf8801e374445ddf7c1c1c46e5b59e615d  net-smtp-0.4.0.1.tar.gz
82265f30a418ecf1248faec6f307aa4c4e4c3176325b0691d600a0fe85803caf8a10fd58391459e16bbd451b3482f543261ee3a4a6b580cc5a1576fe8afebc6e  gemspec.patch
"
